function showImageOverlaySearch(){
	window.location.href="showImageOverlaySearch.do";
}

function ajaxFindImageOverlaySearchList(currentPage,pageSize) {
	$.ajax({
		type:"post",
		url: "ajaxImageOverlaySearchList.do",
		data:{
			currentPage:currentPage,
			pageSize:pageSize,
		},
		success:function(msg){
			$("#listImageOverlayBox").html(msg);
		}
	});
}

function ajaxShowImageOverlayEdit(id){
	$.ajax({
		type:"post",
		url:"ajaxShowImageOverlayEdit.do",
		data:{imageOverlayId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 750,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons: [
				          {
				        	  text: "保存",
				        	  click: function() {
				        		  ajaxSaveImageOverlay(this);
				        	  }
				          },
				          {
				        	  text: "关闭",
				        	  click: function() {
				        		  $(this).dialog( "close" );
				        	  }
				          }
				          ]
			});
		}
	});
}

function ajaxSaveImageOverlay(objDialog) {
	imageOverlayValidate();
	if ($("#frmImageOverlay").valid()) {
		$(objDialog).dialog("close");
		var options ={
				type: "post",
				url : "ajaxSaveImageOverlay.do",
				success: function (msg) {
					clearInput("#sltImageOverlay");
					ajaxFindImageOverlaySearchList();
					showMessageDialog("提示","违法行为信息保存成功。",null,dialogType.info);
				}
		};
		$("#frmImageOverlay").ajaxSubmit(options);
	}
}

function ajaxShowImageOverlayView(id){
	$.ajax({
		type:"post",
		url:"ajaxShowImageOverlayView.do",
		data:{id:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 750,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons : [ {
					text : "关闭",
					click : function() {
						$(this).dialog("close");
					}
				} ]
			});
		}
	});
}

function ajaxDeleteImageOverlayById(id) {
	var imageOverlayIds="";
	var sltIA = $("#listImageOverlayList tbody input:checked").length;
	if(id==null){
		$("#listImageOverlayList tbody input:checked").each(function(){ 
			imageOverlayIds += $(this).val()+";";
		});
		if (imageOverlayIds == ""){
			showMessageDialog("提示","请选择一行或多行",null,dialogType.info);
			return;
		}else{
			imageOverlayIds=imageOverlayIds.substring(0, imageOverlayIds.length-1);
		}
	}else{
		imageOverlayIds=id;
		sltIA = 1;
	}
	if (imageOverlayIds!=null) {
		showMessageDialog("删除违法行为信息","确定要删除所选“"+sltIA+"”条违法行为信息记录吗？",
				function () {
			$.ajax({					
				type:"post",
				url:"ajaxDeleteImageOverlayByIds.do",
				data:{imageOverlayIds:imageOverlayIds},
				success:function(msg){
					ajaxFindImageOverlaySearchList();
					showMessageDialog("提示","告知规则删除成功",null,dialogType.info);
				}
			});}
		,dialogType.warning);
	} 
}

function imageOverlayValidate(){
	$("#frmImageOverlay").validate({
		errorLabelContainer: $("#infoImageOverlay"),
		rules : {
			sectionname : {
				required :true				
			},
			endmeter : {
				required :true,
			}
		},
		messages : {
			sectionname : {
				required :"请输入路段名称！"
			},
			endmeter : {
				required :"请输入结束米数！",
			}
		},
		success: function(label) {
			label.html("&nbsp;");
		}
	});
}